#!/usr/bin/env python
# coding: utf-8

# ## 第二章

# In[12]:


# 运算符
a = 10 
b = 21 
x = 5.2 
y = 2.5
print("a+b=",a+b)
print("x+y=",x+y)
print("a-b=",a-b)
print("x-y=",x-y)
print("a*b=",a*b)
print("x*y=",x*y)
print("b/a=",b/a)
print("x/y=",x/y)
print("b%a=",b%a)
print("y%x=",y%x)
print("a的b次方=",a**b)
print("x的y次方=",x**y)
print("b//a=",b//a)
print("x//y=",x//y)


# In[16]:


# 计算长方形的面积
long = 2.5
width = 2
print("长方形的面积为",long*width,"cm^2")


# In[34]:


day = str((31+15)%7)
print("2月15日是星期",day)


# In[32]:


# 2022-8-17 3   2022-9-13
day = (31+13)%7
print("2022年9月13日是星期",day)


# In[38]:


#计算长方形面积
long = float(input("请输入长方形的长："))
width = float(input("请输入长方形的宽:"))
area = long*width
print("长方形的面积为",area,"cm^2"  ,type(area))


# In[40]:


#字符串类型
str1 = "abc"
str2 = "bcd"
add_result = str1 + str2
print(add_result)
mul_result1 = str1 * 3
mul_result2 = str2 *5
print(mul_result1)
print(mul_result2)


# In[50]:


#数据类型转换
# 整形转换浮点和字符串
a = 20
b = float(20)
print(b,type(b))
c = str(a)
print(c,type(c))
#浮点转换整形和字符串
a = 2.6
b = int(a)
print(b,type(b))
c = str(b)
print(c,type(c))
#字符串转换整形和浮点
a = "2.666"
b = "123"
d = int(b)
print(d,type(d))
c = float(b)
print(c,type(c))


# In[ ]:




